<template>
  <FormView
    v-model="entity"
    :title="entity.id ? '课题信息' : '新建课题'"
    :toolbar-attrs="{ buttons: ['back', { save: isEnabled, edit: isDisabled }, 'cancel'] }"
    :toolbar-listeners="{ save: persist }">
    <template #toolbar-right> </template>
    <FormHolder ref="form" label-width="130px" :disabled="isDisabled" :model="entity">
      <FormItemGroup block-title="基本信息">
        <FormInput v-model="entity.name" prop="name" label="课题名称" required />
        <FormInputDepartment :name.sync="entity.undertakingUnit" prop="undertakingUnit" label="承担单位" required />
        <FormInputUser :id.sync="entity.masterId" :name.sync="entity.masterName" prop="masterName" label="负责人姓名" required />
        <FormInputNumber v-model="entity.funds" prop="funds" label="总经费" required>
          <template #append>万元</template>
        </FormInputNumber>
        <FormInput v-model="entity.projectName" prop="projectName" label="所属项目名称" required />
        <FormTextarea v-model="entity.remark" prop="remark" label="备注" max-length="1500" rows="10" />
      </FormItemGroup>
    </FormHolder>
  </FormView>
</template>

<script>
  import { save, create, load, update } from './api'
  import form from '@/vue/mixin/form'

  export default {
    name: 'ProjectTopicForm',
    docType: '',
    relativeViewId: 'ProjectTopicView',
    mixins: [form],
    data() {
      return {
        entity: {
          id: null,
          unid: null,
          createTime: null,
          createBy: null,
          createId: null,
          deptId: null,
          deptFullName: null,
          updateTime: null,
          updateId: null,
          updateBy: null,
          tenantId: null,
          delFlag: null,
          name: null,
          undertakingUnit: null,
          masterId: null,
          masterName: null,
          funds: null,
          remark: null,
          projectId: null,
          projectName: null
        }
      }
    },
    methods: {
      create,
      load,
      save,
      update
    }
  }
</script>
